import DataStore from "./DataStore.js"
class Sprite {
  constructor(img = null, sx = 0, sy = 0, sw = 0, sh = 0, x = 0, y = 0, w = 0, h = 0) {
    this.dataStore = DataStore.getInstance()
    this.ctx = this.dataStore.ctx
    this.img = img
    this.sx = sx
    this.sy = sy
    this.sw = sw
    this.sh = sh
    this.x = x
    this.y = y
    this.w = w
    this.h = h
  }
  static getImage(key) {
    return DataStore.getInstance().res.get(key)
  }
  draw(img = this.img, 
    sx = this.sx, sy = this.sy, sw = this.sw, sh = this.sh,
    x = this.x, y = this.y, w = this.w, h = this.h) {
    this.ctx.drawImage(img, sx, sy, sw, sh, x, y, w, h)
  }
}

export default Sprite